package com.example.demo.controller;

import cn.hutool.json.JSONUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author: Bin.L
 * @date: 2021/9/8 0008 21:19
 * @Description:
 */

@Slf4j
@Api(tags = "React练习请求用")
@RestController()
@RequestMapping("/reactPractise")
public class ReactPractiseController {

    @Getter
    @Setter
    @ToString
    @EqualsAndHashCode
    static class Student {
        private String id;
        private String name;
        private Integer age;
    }

    @GetMapping("/listStudent")
    @ApiOperation(value = "查询所有学生", notes = "查询所有学生")
    public List<Student> listStudent() {
        String str = "[{\"id\":\"1\",\"name\":\"张三\",\"age\":20},{\"id\":\"2\",\"name\":\"LiLei\",\"age\":23},{\"id\":\"3\",\"name\":\"Duoer\",\"age\":19}]";
        List<Student> students = JSONUtil.toList(str, Student.class);
        return students;
    }

}
